<?php
if(!isset($_SESSION)) 
	{ 
		session_start(); 
	}
$selectProM = mysql_query("SELECT e.FullName,pr.NameProject,pr.IDProject,pr.`Status`,DATE_FORMAT(pr.DateStart,'%Y-%m-%d') as DateStart
						 FROM employee e,pr_project pr
 						WHERE e.IDManager = pr.IDManager AND e.IDEmployee = '$id_employee'");

//$selectpro = mysql_query("SELECT p.IDProject, p.NameProject, e.FullName, DATE_FORMAT(p.DateStart,'%Y-%m-%d') as DateStart, p.`Status`
  //       FROM pr_project p,pr_composition c, employee e 
   //      WHERE c.IDEmployee = '$id_employee' AND p.IDProject = c.IDProject AND e.IDEmployee = c.IDEmployee AND (e.IDManager != p.IDManager) 
   //      GROUP BY p.IDProject ORDER BY p.NameProject ASC");
   $selectpro = mysql_query("SELECT p.IDProject, p.NameProject, e.FullName, DATE_FORMAT(p.DateStart,'%Y-%m-%d') as DateStart, p.`Status`
         FROM pr_project p,pr_composition c, employee e 
         WHERE c.IDEmployee = '$id_employee' AND p.IDProject = c.IDProject AND e.IDManager = p.IDManager  
         GROUP BY p.IDProject ORDER BY p.NameProject ASC");
?>
<link
	href="css/style.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript">
        $(document).ready(function() {
            $('.sub_app').hide();
            $('.app_tt:first').addClass('active');
            
            $('.app_tt').click(function() {
                $('.active').removeClass('active');
                $('.sub_app').slideUp('normal');
                if($(this).next('.sub_app').is(':hidden') == true) {
                $(this).addClass('active');
                $(this).next('.sub_app').slideDown('normal');
                }
            });
            $('.app_tt').hover(function(){//over
                $(this).addClass('on');
            },function() {//out
                $(this).removeClass('on');
            });
            
            $('#<?=$append?>').click();
        });
     </script>
    
<div id="contains" style="background-color: #edf4f7;">

	<div class="title"></div>
	<div class="body" id="contentLstPro">
		<div class="nav_top" style="width: 100%;">
       		<div class="nav_tit"><?php echo $l_projectlist;?></div>     
            <div class="rehome"><a href="mainPhone.php"><?php echo $l_menu?></a></div>       
       	</div>
		<div id="listProjectM" style="margin-left: 10px;" class="main_app">
			<h1>
            	<span class="top_col"></span>
                <div class="app_tt" ><?php echo $l_projectlist." - ".$l_manager?></div>
			<div class="sub_app">
			<table id="listProM" width="100%" class="cssTable">
				<thead>
					<tr style="background-color: #216ca3;">
						<th scope="col" style="width: 30%;border-right: 1px solid dotted;"><?php echo $l_project_name?></th>
						<th scope="col" style="width: 25%;border-right: 1px solid dotted;"><?php echo $l_manager?></th>
						<th scope="col" style="width: 20%;border-right: 1px solid dotted;"><?php echo $l_status?></th>
						<th scope="col" style="width: 25%;"><?php echo $l_start_date?></th>
					</tr>
					<?php
					while ($rowM = mysql_fetch_array($selectProM)){
						?>
					<tr style="background-color: #edf4f7;">
						<td style="width: 30%;vertical-align: middle;font-weight: normal;border-right: 1px dotted">
						<a style="font-weight: normal;color: blue;" href="project.php?projectDetail=project-detail&id=<?=$rowM[IDProject]?>"><?php echo $rowM[NameProject]?></a></td>
						<td style="width: 30%;vertical-align: middle;font-weight: normal;border-right: 1px dotted"><?php echo $rowM[FullName]?></td>
						<td style="width: 30%;vertical-align: middle;font-weight: normal;border-right: 1px dotted"><?php if($rowM[`Status`]==0){echo $l_status_project_no;}else if($rowM[`Status`]==1){echo $l_status_project_done;}?>
						</td>
						<td style="width: 30%;vertical-align: middle;font-weight: normal;border-right: 1px dotted"><?php echo $rowM[DateStart]?></td>
					</tr>
					<?php
					}
					?>
				</thead>
			</table></div></h1>
		</div>

		<div id="listProject" style="margin-left: 10px;" class="main_app">
			<h1>
            	<span class="top_col"></span>
                <div class="app_tt" ><?php echo $l_projectlist." - ".$l_memb?></div>
			<div class="sub_app">
			<table id="listPro" width="100%" class="cssTable"
				style="background: #216ca3;">
				<thead>
					<tr>
						<th scope="col" style="width: 30%;border-right: 1px solid dotted;"><?php echo $l_project_name?></th>
						<th scope="col" style="width: 25%;border-right: 1px solid dotted;"><?php echo $l_manager?></th>
						<th scope="col" style="width: 20%;border-right: 1px solid dotted;"><?php echo $l_status?></th>
						<th scope="col" style="width: 25%;"><?php echo $l_start_date?></th>
					</tr>
					<?php 
						while ($row = mysql_fetch_array($selectpro)){
							?>
							<tr style="background-color: #edf4f7;">
						<td style="width: 30%;vertical-align: middle;border-right: 1px dotted"><a style="font-weight: normal;color: blue;" href="project.php?projectDetail=project-detail&id=<?=$row[IDProject]?>"><?php echo $row[NameProject]?></a></td>
						<td style="width: 25%;vertical-align: middle;font-weight: normal;border-right: 1px dotted"><?php echo $row[FullName]?></td>
						<td style="width: 20%;vertical-align: middle;font-weight: normal;border-right: 1px dotted"><?php if($row[`Status`]==0){echo $l_status_project_no;}else if($row[`Status`]==1){echo $l_status_project_done;}?>
						</td>
						<td style="width: 25%;vertical-align: middle;font-weight: normal;border-right: 1px dotted"><?php echo $row[DateStart]?></td>
					</tr>
							<?php 
						}
					?>
				</thead>
			</table>
			</div></h1>
		</div>
	</div>
</div>
